package
{
	import flash.utils.getTimer;

	public class SimulationManager
	{
		private var m_lastTick:int;
		private var m_simulationObjects:Vector.<ISimObject>;
		
		public function SimulationManager()
		{
			m_simulationObjects = new Vector.<ISimObject>;
			m_lastTick = getTimer();
		}
		 
		public function add(simObject:ISimObject):void{
			m_simulationObjects.push(simObject);
		}
		
		public function update():void{
			var i:int, length:int;
			var simObject:ISimObject;
			var curTick:int = getTimer();
			var delta:int = curTick - m_lastTick;
			Global.fps = delta / 1000;
			for(i = 0, length = m_simulationObjects.length; i < length; i++){
				simObject = m_simulationObjects[i];
				simObject.updateCurrentState();
				simObject.setupNextState(delta);
			}			
			
			m_lastTick = curTick;
		}
	}
}